// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate grafeas;
extern crate iam_v1;
extern crate lazy_static;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// The request to generate and export SBOM. Target must be specified for the
/// request.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ExportSBOMRequest {
    /// Required. The name of the resource in the form of
    /// `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
    pub name: std::string::String,

    /// The location of the SBOM export.
    pub target: std::option::Option<crate::model::export_sbom_request::Target>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ExportSBOMRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ExportSBOMRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [target][crate::model::ExportSBOMRequest::target].
    ///
    /// Note that all the setters affecting `target` are mutually
    /// exclusive.
    pub fn set_target<
        T: std::convert::Into<std::option::Option<crate::model::export_sbom_request::Target>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.target = v.into();
        self
    }

    /// The value of [target][crate::model::ExportSBOMRequest::target]
    /// if it holds a `CloudStorageLocation`, `None` if the field is not set or
    /// holds a different branch.
    pub fn cloud_storage_location(
        &self,
    ) -> std::option::Option<
        &std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
    > {
        #[allow(unreachable_patterns)]
        self.target.as_ref().and_then(|v| match v {
            crate::model::export_sbom_request::Target::CloudStorageLocation(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [target][crate::model::ExportSBOMRequest::target]
    /// to hold a `CloudStorageLocation`.
    ///
    /// Note that all the setters affecting `target` are
    /// mutually exclusive.
    pub fn set_cloud_storage_location<
        T: std::convert::Into<
                std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
            >,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.target = std::option::Option::Some(
            crate::model::export_sbom_request::Target::CloudStorageLocation(v.into()),
        );
        self
    }
}

impl wkt::message::Message for ExportSBOMRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMRequest"
    }
}

/// Defines additional types related to [ExportSBOMRequest].
pub mod export_sbom_request {
    #[allow(unused_imports)]
    use super::*;

    /// Empty placeholder to denote that this is a Google Cloud Storage
    /// export request.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct CloudStorageLocation {
        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl CloudStorageLocation {
        pub fn new() -> Self {
            std::default::Default::default()
        }
    }

    impl wkt::message::Message for CloudStorageLocation {
        fn typename() -> &'static str {
            "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMRequest.CloudStorageLocation"
        }
    }

    /// The location of the SBOM export.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Target {
        /// Optional. Empty placeholder to denote that this is a Google Cloud Storage
        /// export request.
        CloudStorageLocation(
            std::boxed::Box<crate::model::export_sbom_request::CloudStorageLocation>,
        ),
    }
}

/// The response from a call to ExportSBOM.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ExportSBOMResponse {
    /// The name of the discovery occurrence in the form
    /// "projects/{project_id}/occurrences/{OCCURRENCE_ID}
    /// It can be used to track the progress of the SBOM export.
    pub discovery_occurrence: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ExportSBOMResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [discovery_occurrence][crate::model::ExportSBOMResponse::discovery_occurrence].
    pub fn set_discovery_occurrence<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.discovery_occurrence = v.into();
        self
    }
}

impl wkt::message::Message for ExportSBOMResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.containeranalysis.v1.ExportSBOMResponse"
    }
}

/// Request to get a vulnerability summary for some set of occurrences.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetVulnerabilityOccurrencesSummaryRequest {
    /// Required. The name of the project to get a vulnerability summary for in the
    /// form of `projects/[PROJECT_ID]`.
    pub parent: std::string::String,

    /// The filter expression.
    pub filter: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetVulnerabilityOccurrencesSummaryRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::GetVulnerabilityOccurrencesSummaryRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::GetVulnerabilityOccurrencesSummaryRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }
}

impl wkt::message::Message for GetVulnerabilityOccurrencesSummaryRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest"
    }
}

/// A summary of how many vulnerability occurrences there are per resource and
/// severity type.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct VulnerabilityOccurrencesSummary {
    /// A listing by resource of the number of fixable and total vulnerabilities.
    pub counts:
        std::vec::Vec<crate::model::vulnerability_occurrences_summary::FixableTotalByDigest>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl VulnerabilityOccurrencesSummary {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [counts][crate::model::VulnerabilityOccurrencesSummary::counts].
    pub fn set_counts<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<
                crate::model::vulnerability_occurrences_summary::FixableTotalByDigest,
            >,
    {
        use std::iter::Iterator;
        self.counts = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for VulnerabilityOccurrencesSummary {
    fn typename() -> &'static str {
        "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary"
    }
}

/// Defines additional types related to [VulnerabilityOccurrencesSummary].
pub mod vulnerability_occurrences_summary {
    #[allow(unused_imports)]
    use super::*;

    /// Per resource and severity counts of fixable and total vulnerabilities.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct FixableTotalByDigest {
        /// The affected resource.
        pub resource_uri: std::string::String,

        /// The severity for this count. SEVERITY_UNSPECIFIED indicates total across
        /// all severities.
        pub severity: grafeas::model::Severity,

        /// The number of fixable vulnerabilities associated with this resource.
        pub fixable_count: i64,

        /// The total number of vulnerabilities associated with this resource.
        pub total_count: i64,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl FixableTotalByDigest {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [resource_uri][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::resource_uri].
        pub fn set_resource_uri<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.resource_uri = v.into();
            self
        }

        /// Sets the value of [severity][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::severity].
        pub fn set_severity<T: std::convert::Into<grafeas::model::Severity>>(
            mut self,
            v: T,
        ) -> Self {
            self.severity = v.into();
            self
        }

        /// Sets the value of [fixable_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::fixable_count].
        pub fn set_fixable_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
            self.fixable_count = v.into();
            self
        }

        /// Sets the value of [total_count][crate::model::vulnerability_occurrences_summary::FixableTotalByDigest::total_count].
        pub fn set_total_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
            self.total_count = v.into();
            self
        }
    }

    impl wkt::message::Message for FixableTotalByDigest {
        fn typename() -> &'static str {
            "type.googleapis.com/google.devtools.containeranalysis.v1.VulnerabilityOccurrencesSummary.FixableTotalByDigest"
        }
    }
}
